package com.awa.usercenter.common.utils;

import com.awa.usercenter.common.BaseResponse;
import com.awa.usercenter.common.Code;

/**
 * 返回工具类
 */
public class ResultUtils {

    /**
     * 成功
     *
     */
    public static BaseResponse success(Object data){
        return new BaseResponse(1, data, "ok");
    }
    public static BaseResponse successMsg(String message){
        return new BaseResponse(1, null, message);
    }

    /**
     * 失败
     *
     */
    public static BaseResponse error(Code code){
        return new BaseResponse<>(code);
    }
    public static BaseResponse errorMsg(String message){
        return new BaseResponse(0, null, message);
    }
    /**
     * 失败
     *
     */
    //code自定义
    public static BaseResponse error(int code, String message, String discription){
        return new BaseResponse<>(code, null, message, discription);
    }

    /**
     * 失败
     *
     */
    public static BaseResponse error(Code code, String message, String description){
        return new BaseResponse(code.getCode(), null, message, description);
    }

    /**
     * 失败
     *
     */
    public static BaseResponse error(Code code, String description){
        return new BaseResponse(code.getCode(), null, code.getMessage(), description);
    }


}
